package com.demo.base;

import lombok.*;

import java.util.*;

/**
 * AIKA
 * 2024/6/3
 */

@Data
public class BasePage {

    private Integer id;

    private String  name;

    private Integer pageNum = 0;

    private Integer pageSize = 10;

    /**
     *  手动分页
     */
    public static List splitPageList(List list, Integer index, Integer size) {
        int totalCount = list.size();
        int totalPage = (totalCount + size - 1) / size;
        int start = (index - 1) * size;
        int end = Math.min(start + size, totalCount);
        if (start >= end) {
            return new ArrayList<>();
        }
        return list.subList(start, end);
    }

}
